﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMobile.Forms;

namespace smart_test
{
    public partial class OpenFileFrm : Form
    {
        public string filename;

        public OpenFileFrm()
        {
            InitializeComponent();
            this.Load += new EventHandler(OpenFileFrm_Load);
        }

        void OpenFileFrm_Load(object sender, EventArgs e)
        {
            SelectPictureDialog spd = new SelectPictureDialog();
            spd.Owner = this;
            spd.Title = "Select a picture";
            spd.CameraAccess = false;
            spd.LockDirectory = true;

            if (spd.ShowDialog() == DialogResult.OK)
            {
                openFileImage.Image = new Bitmap(spd.FileName);
                filename = spd.FileName;
            }
            else
            {
                this.Close();
                return;
            }
        }

        private void btBack_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btOpen_Click(object sender, EventArgs e)
        {
            SelectPictureDialog spd = new SelectPictureDialog();
            spd.Owner = this;
            spd.Title = "Select a picture";
            spd.CameraAccess = false;
            spd.LockDirectory = true;

            if (spd.ShowDialog() == DialogResult.OK)
            {
                openFileImage.Image = new Bitmap(spd.FileName);
                filename = spd.FileName;
            }
            else
            {
                return;
            }
        }

        private void btUpload_Click(object sender, EventArgs e)
        {
            UploadFrm uf = new UploadFrm(filename);
            uf.Show();
            this.Close();
        }

        private void btOpen_MouseDown(object sender, MouseEventArgs e)
        {
            btOpenPress.Visible = true;
        }

        private void btOpen_MouseUp(object sender, MouseEventArgs e)
        {
            btOpenPress.Visible = false;
        }

        private void btBack_MouseUp(object sender, MouseEventArgs e)
        {
            btBackPress.Visible = false;
        }

        private void btBack_MouseDown(object sender, MouseEventArgs e)
        {
            btBackPress.Visible = true;
        }

        private void btUpload_MouseDown(object sender, MouseEventArgs e)
        {
            btUploadPress.Visible = true;
        }

        private void btUpload_MouseUp(object sender, MouseEventArgs e)
        {
            btUploadPress.Visible = false;
        }
    }
}